package com.cn.wanxi.service;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;

public class NewsService {


    public NewsModel[] getNewsModelsForNewsPage() {

        NewsDao newsDao = new NewsDao();
        NewsModel[] newsModels = new NewsModel[newsDao.titlesForNewsPage.length];
        for (int i = 0; i < newsModels.length; i++) {
            NewsModel model = new NewsModel();
            model.setTitle(newsDao.titlesForNewsPage[i]);
            model.setContent(newsDao.contentsForNewsPage[i]);
            model.setCreateTime(newsDao.createTimeForNewsPage[i]);
            newsModels[i] = model;
        }
        return newsModels;
    }

    public NewsModel[] getNewsModelsForHomePage() {
        NewsModel[] newsModels = new NewsModel[3];
        NewsDao newsDao = new NewsDao();
        for (int i = 0; i < newsModels.length; i++) {
            NewsModel model = new NewsModel();
            model.setTitle(newsDao.titlesForHomePage[i]);
            model.setContent(newsDao.contentsForHomePage[i]);
            newsModels[i] = model;
        }
        return newsModels;
    }
}
